/*
指针和引用的共性，都可以对确切的变量本身（指内存）进行索引
*/
#include <iostream>
void swap(int &p1, int &p2) //此处函数的形参p1, p2都是引用
{
    int p;
    p = p1;
    p1 = p2;
    p2 = p;
}
void swap1(int p1, int p2) //此处函数的形参p1, p2都不是引用
{
    int p;
    p = p1;
    p1 = p2;
    p2 = p;
}
void swap2(int *p1, int *p2)    //指针
{
    int p;
    p = *p1;
    *p1 = *p2;
    *p2 = p; 
}
int main(void)
{
    int a = 10, b = 20;
    int c = 10, d = 20;
    int e = 10, f = 20;
    int *ptr_e = &e, *ptr_f = &f;
    swap(a, b);
    swap1(c,d);
    swap2(ptr_e,ptr_f);
    std::cout << a << " " << b << std::endl;
    std::cout << c << " " << d << std::endl; 
    std::cout << e << " " << f << std::endl;
    return 0;
}